package com.kime.jwt.service;

import com.kime.jwt.dao.UserDao;
import com.kime.jwt.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public User login(User user) {
        // 根据接收的用户名密码查询数据库
        User userInfo = userDao.login(user);
        if (userInfo != null) {
            return userInfo;
        }
        throw new RuntimeException("认证失败～～");
    }
}
